package com.itheima.edu.info.manager.ceshi;

import java.io.*;
import java.net.Socket;

public class SocketTest {
    public static void main(String[] args) throws IOException {
        //创建客户端
        Socket s=new Socket("127.0.0.1",4396);
        //向服务器接收数据并打印
        BufferedReader br1=new BufferedReader(new InputStreamReader(s.getInputStream()));
        String string="";
        while ((string=br1.readLine())!=null){
            System.out.println(string);
        }

        //向服务器发送数据
        BufferedReader br=new BufferedReader(new FileReader("D:\\百度云\\下载\\新建文件夹\\" +
                "新建文件夹\\新建文件夹\\day04\\day04笔记.txt"));
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
        int a;
        while ((a=br.read())!=-1){
            bw.write(a);
            bw.flush();
        }
        s.shutdownOutput();
        BufferedReader br2=new BufferedReader(new InputStreamReader(s.getInputStream()));
        String string1="";
        while ((string1=br2.readLine())!=null){
            System.out.println(string1);
        }
        bw.close();
        s.close();


    }

        }




